﻿<UserControl x:Class="WpfPersianDatePickerUsage.Views.TestView2"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"              
             xmlns:dp="clr-namespace:WpfPersianDatePicker.Views;assembly=WpfPersianDatePicker" 
             xmlns:conv="clr-namespace:WpfPersianDatePicker.Converters;assembly=WpfPersianDatePicker" 
             xmlns:ViewModels="clr-namespace:WpfPersianDatePickerUsage.ViewModels" 
             FlowDirection="RightToLeft" FontFamily="Tahoma" FontSize="11"             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ViewModels:TestView2ViewModel x:Key="vmTestView2ViewModel" />
        <conv:ToPersianDateConverter x:Key="ToPersianDateConverterConv" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" 
          DataContext="{Binding Source={StaticResource vmTestView2ViewModel}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="116" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="1"  Margin="5"  Text="نام كاربر"  />
        <TextBlock Grid.Row="2" Margin="5"  Text="اعتبار حساب كاربري تا"  />

        <TextBox Grid.Column="1" Grid.Row="1" 
                 Margin="5" Text="{Binding ElementName=listBox1, Path=SelectedItem.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <dp:PDatePicker                 
                TextBoxWidth="100"
                SelectedDate="{Binding ElementName=listBox1, Path=SelectedItem.AccountValidTo, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                Grid.Column="1" 
                Grid.Row="2" 
                Margin="5" TextBoxIsReadOnly="False"
                VerticalAlignment="Top"
                />
        <ListBox 
            Grid.Column="1" 
            Grid.Row="0" 
            Height="100" 
            ItemsSource="{Binding Users}"
            Margin="5"
            SelectedIndex="0"
            IsSynchronizedWithCurrentItem="True"
            Name="listBox1" 
            VerticalAlignment="Top">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Name}" Margin="2"/>
                        <TextBlock Text=" - " Margin="2"/>
                        <TextBlock Text="{Binding AccountValidTo, 
                            Converter={StaticResource ToPersianDateConverterConv}}" Margin="2"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>    
</UserControl>
